﻿using Nancy.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection.Metadata;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace Lian_java
{
    class Program
    {
        static void Main(string[] args)
        {
            ////将数据保存到bb.txt
            //List<Class1> class1s = Class2.li();
            //Class3 class3 = new Class3();
            //string a1 = Path.Combine(class3.lu,"aaa",@"bb.txt");//创建bb.txt文档
            //using (Stream a2 = new FileStream(a1, FileMode.Create, FileAccess.ReadWrite)) {
            //    //BinaryFormatter a3 = new BinaryFormatter();//使用二进制序列化
            //    XmlSerializer a3 = new XmlSerializer(typeof(List<Class1>));//xml序列化
            //    a3.Serialize(a2, class1s);//把class1s中数据经过二进制序列化添加到bb.txt文档中
            //}

            ////读取bb.txt中的数据
            //using (Stream a4 = new FileStream(a1, FileMode.Open, FileAccess.ReadWrite)) {
            //    //BinaryFormatter a5 = new BinaryFormatter();
            //    XmlSerializer a5 = new XmlSerializer(typeof(List<Class1>));
            //    a4.Position = 0;
            //    var a6 = a5.Deserialize(a4);
            //}

            //json序列化
            List<Class1> class1s = Class2.li();
            JavaScriptSerializer jss = new JavaScriptSerializer();
            string a1= jss.Serialize(class1s);//序列化
            List<Class1> a2 = jss.Deserialize<List<Class1>>(a1);//反序列化
        }
    }

}
